﻿using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a camera setup model.</summary>
	// Token: 0x0200001E RID: 30
	[Serializable]
	public class HCameraSetupModel : HHandle, ISerializable, ICloneable
	{
		// Token: 0x060001E2 RID: 482 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HCameraSetupModel() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x060001E3 RID: 483 RVA: 0x0000ABB8 File Offset: 0x00008DB8
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HCameraSetupModel(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060001E4 RID: 484 RVA: 0x0000ABC7 File Offset: 0x00008DC7
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HCameraSetupModel(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060001E5 RID: 485 RVA: 0x0000ABD6 File Offset: 0x00008DD6
		private void AssertSemType()
		{
			base.AssertSemType("camera_setup_model");
		}

		// Token: 0x060001E6 RID: 486 RVA: 0x0000ABE3 File Offset: 0x00008DE3
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HCameraSetupModel obj)
		{
			obj = new HCameraSetupModel(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x060001E7 RID: 487 RVA: 0x0000ABFC File Offset: 0x00008DFC
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HCameraSetupModel[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HCameraSetupModel[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HCameraSetupModel(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Restore a camera setup model from a file.
		///   Modified instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="fileName">The path and file name of the model file.</param>
		// Token: 0x060001E8 RID: 488 RVA: 0x0000AC6C File Offset: 0x00008E6C
		public HCameraSetupModel(string fileName)
		{
			IntPtr proc = HalconAPI.PreCall(1954);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a model for a setup of calibrated cameras.
		///   Modified instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="numCameras">Number of cameras in the setup. Default: 2</param>
		// Token: 0x060001E9 RID: 489 RVA: 0x0000ACB8 File Offset: 0x00008EB8
		public HCameraSetupModel(int numCameras)
		{
			IntPtr proc = HalconAPI.PreCall(1958);
			HalconAPI.StoreI(proc, 0, numCameras);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		// Token: 0x060001EA RID: 490 RVA: 0x0000AD04 File Offset: 0x00008F04
		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = this.SerializeCameraSetupModel();
			byte[] value = hserializedItem;
			hserializedItem.Dispose();
			info.AddValue("data", value, typeof(byte[]));
		}

		// Token: 0x060001EB RID: 491 RVA: 0x0000AD3C File Offset: 0x00008F3C
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HCameraSetupModel(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = new HSerializedItem((byte[])info.GetValue("data", typeof(byte[])));
			this.DeserializeCameraSetupModel(hserializedItem);
			hserializedItem.Dispose();
		}

		/// <summary>Serialize object to binary stream in HALCON format</summary>
		// Token: 0x060001EC RID: 492 RVA: 0x0000AD7C File Offset: 0x00008F7C
		public new void Serialize(Stream stream)
		{
			HSerializedItem hserializedItem = this.SerializeCameraSetupModel();
			hserializedItem.Serialize(stream);
			hserializedItem.Dispose();
		}

		/// <summary>Deserialize object from binary stream in HALCON format</summary>
		// Token: 0x060001ED RID: 493 RVA: 0x0000AD90 File Offset: 0x00008F90
		public new static HCameraSetupModel Deserialize(Stream stream)
		{
			HCameraSetupModel hcameraSetupModel = new HCameraSetupModel();
			HSerializedItem hserializedItem = HSerializedItem.Deserialize(stream);
			hcameraSetupModel.DeserializeCameraSetupModel(hserializedItem);
			hserializedItem.Dispose();
			return hcameraSetupModel;
		}

		// Token: 0x060001EE RID: 494 RVA: 0x0000ADB6 File Offset: 0x00008FB6
		object ICloneable.Clone()
		{
			return this.Clone();
		}

		// Token: 0x060001EF RID: 495 RVA: 0x0000ADC0 File Offset: 0x00008FC0
		public new HCameraSetupModel Clone()
		{
			HSerializedItem hserializedItem = this.SerializeCameraSetupModel();
			HCameraSetupModel hcameraSetupModel = new HCameraSetupModel();
			hcameraSetupModel.DeserializeCameraSetupModel(hserializedItem);
			hserializedItem.Dispose();
			return hcameraSetupModel;
		}

		/// <summary>
		///   Create a HALCON stereo model.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="method">Reconstruction method. Default: "surface_pairwise"</param>
		/// <param name="genParamName">Name of the model parameter to be set. Default: []</param>
		/// <param name="genParamValue">Value of the model parameter to be set. Default: []</param>
		/// <returns>Handle of the stereo model.</returns>
		// Token: 0x060001F0 RID: 496 RVA: 0x0000ADE8 File Offset: 0x00008FE8
		public HStereoModel CreateStereoModel(string method, HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(527);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, method);
			HalconAPI.Store(proc, 2, genParamName);
			HalconAPI.Store(proc, 3, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HStereoModel result;
			num = HStereoModel.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Create a HALCON stereo model.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="method">Reconstruction method. Default: "surface_pairwise"</param>
		/// <param name="genParamName">Name of the model parameter to be set. Default: []</param>
		/// <param name="genParamValue">Value of the model parameter to be set. Default: []</param>
		/// <returns>Handle of the stereo model.</returns>
		// Token: 0x060001F1 RID: 497 RVA: 0x0000AE54 File Offset: 0x00009054
		public HStereoModel CreateStereoModel(string method, string genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(527);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, method);
			HalconAPI.StoreS(proc, 2, genParamName);
			HalconAPI.Store(proc, 3, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamValue);
			HStereoModel result;
			num = HStereoModel.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Free the memory of a calibration setup model.
		///   Instance represents: Handle of the camera setup model.
		/// </summary>
		// Token: 0x060001F2 RID: 498 RVA: 0x0000AEBC File Offset: 0x000090BC
		public void ClearCameraSetupModel()
		{
			IntPtr proc = HalconAPI.PreCall(1950);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Serialize a camera setup model.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <returns>Handle of the serialized item.</returns>
		// Token: 0x060001F3 RID: 499 RVA: 0x0000AEF0 File Offset: 0x000090F0
		public HSerializedItem SerializeCameraSetupModel()
		{
			IntPtr proc = HalconAPI.PreCall(1951);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HSerializedItem result;
			num = HSerializedItem.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Deserialize a serialized camera setup model.
		///   Modified instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="serializedItemHandle">Handle of the serialized item.</param>
		// Token: 0x060001F4 RID: 500 RVA: 0x0000AF38 File Offset: 0x00009138
		public void DeserializeCameraSetupModel(HSerializedItem serializedItemHandle)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1952);
			HalconAPI.Store(proc, 0, serializedItemHandle);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(serializedItemHandle);
		}

		/// <summary>
		///   Store a camera setup model into a file.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="fileName">The file name of the model to be saved.</param>
		// Token: 0x060001F5 RID: 501 RVA: 0x0000AF8C File Offset: 0x0000918C
		public void WriteCameraSetupModel(string fileName)
		{
			IntPtr proc = HalconAPI.PreCall(1953);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, fileName);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Restore a camera setup model from a file.
		///   Modified instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="fileName">The path and file name of the model file.</param>
		// Token: 0x060001F6 RID: 502 RVA: 0x0000AFC8 File Offset: 0x000091C8
		public void ReadCameraSetupModel(string fileName)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1954);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Get generic camera setup model parameters.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="cameraIdx">Index of the camera in the setup. Default: 0</param>
		/// <param name="genParamName">Names of the generic parameters to be queried.</param>
		/// <returns>Values of the generic parameters to be queried.</returns>
		// Token: 0x060001F7 RID: 503 RVA: 0x0000B014 File Offset: 0x00009214
		public HTuple GetCameraSetupParam(HTuple cameraIdx, string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(1955);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, cameraIdx);
			HalconAPI.StoreS(proc, 2, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(cameraIdx);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get generic camera setup model parameters.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="cameraIdx">Index of the camera in the setup. Default: 0</param>
		/// <param name="genParamName">Names of the generic parameters to be queried.</param>
		/// <returns>Values of the generic parameters to be queried.</returns>
		// Token: 0x060001F8 RID: 504 RVA: 0x0000B074 File Offset: 0x00009274
		public HTuple GetCameraSetupParam(int cameraIdx, string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(1955);
			base.Store(proc, 0);
			HalconAPI.StoreI(proc, 1, cameraIdx);
			HalconAPI.StoreS(proc, 2, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Set generic camera setup model parameters.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="cameraIdx">Unique index of the camera in the setup. Default: 0</param>
		/// <param name="genParamName">Names of the generic parameters to be set.</param>
		/// <param name="genParamValue">Values of the generic parameters to be set.</param>
		// Token: 0x060001F9 RID: 505 RVA: 0x0000B0CC File Offset: 0x000092CC
		public void SetCameraSetupParam(HTuple cameraIdx, string genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1956);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, cameraIdx);
			HalconAPI.StoreS(proc, 2, genParamName);
			HalconAPI.Store(proc, 3, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(cameraIdx);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set generic camera setup model parameters.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="cameraIdx">Unique index of the camera in the setup. Default: 0</param>
		/// <param name="genParamName">Names of the generic parameters to be set.</param>
		/// <param name="genParamValue">Values of the generic parameters to be set.</param>
		// Token: 0x060001FA RID: 506 RVA: 0x0000B124 File Offset: 0x00009324
		public void SetCameraSetupParam(int cameraIdx, string genParamName, double genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(1956);
			base.Store(proc, 0);
			HalconAPI.StoreI(proc, 1, cameraIdx);
			HalconAPI.StoreS(proc, 2, genParamName);
			HalconAPI.StoreD(proc, 3, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Define type, parameters, and relative pose of a camera in a camera setup model.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="cameraIdx">Index of the camera in the setup.</param>
		/// <param name="cameraType">Type of the camera. Default: []</param>
		/// <param name="cameraParam">Internal camera parameters.</param>
		/// <param name="cameraPose">Pose of the camera relative to the setup's coordinate system.</param>
		// Token: 0x060001FB RID: 507 RVA: 0x0000B170 File Offset: 0x00009370
		public void SetCameraSetupCamParam(HTuple cameraIdx, HTuple cameraType, HCamPar cameraParam, HTuple cameraPose)
		{
			IntPtr proc = HalconAPI.PreCall(1957);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, cameraIdx);
			HalconAPI.Store(proc, 2, cameraType);
			HalconAPI.Store(proc, 3, cameraParam);
			HalconAPI.Store(proc, 4, cameraPose);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(cameraIdx);
			HalconAPI.UnpinTuple(cameraType);
			HalconAPI.UnpinTuple(cameraParam);
			HalconAPI.UnpinTuple(cameraPose);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Define type, parameters, and relative pose of a camera in a camera setup model.
		///   Instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="cameraIdx">Index of the camera in the setup.</param>
		/// <param name="cameraType">Type of the camera. Default: []</param>
		/// <param name="cameraParam">Internal camera parameters.</param>
		/// <param name="cameraPose">Pose of the camera relative to the setup's coordinate system.</param>
		// Token: 0x060001FC RID: 508 RVA: 0x0000B1E8 File Offset: 0x000093E8
		public void SetCameraSetupCamParam(HTuple cameraIdx, string cameraType, HCamPar cameraParam, HTuple cameraPose)
		{
			IntPtr proc = HalconAPI.PreCall(1957);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, cameraIdx);
			HalconAPI.StoreS(proc, 2, cameraType);
			HalconAPI.Store(proc, 3, cameraParam);
			HalconAPI.Store(proc, 4, cameraPose);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(cameraIdx);
			HalconAPI.UnpinTuple(cameraParam);
			HalconAPI.UnpinTuple(cameraPose);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a model for a setup of calibrated cameras.
		///   Modified instance represents: Handle to the camera setup model.
		/// </summary>
		/// <param name="numCameras">Number of cameras in the setup. Default: 2</param>
		// Token: 0x060001FD RID: 509 RVA: 0x0000B25C File Offset: 0x0000945C
		public void CreateCameraSetupModel(int numCameras)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1958);
			HalconAPI.StoreI(proc, 0, numCameras);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}
	}
}
